package com.dkd.manage.controller;

import com.dkd.common.annotation.Anonymous;
import com.dkd.common.core.controller.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


import java.util.HashMap;
import java.util.Map;


@Anonymous
@Slf4j
@RestController
@RequestMapping("/manage/vehicle")
public class VehicleTemplateController extends BaseController {

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Anonymous
    // POST请求（带JSON Body）
    @PostMapping("/postData")
    public String postData() {
        // 按车辆属性查询过车信息
        String url = "https://172.18.16.170:8443/artemis/api/aiapplication/v1/vehicle/queryVehiclesByAttrWithPage";
        //创建headers
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        log.info("headers:{}",headers);
        //创建body
        Map<String, Object> body = new HashMap<>();
        body.put("pageNo",1);
        body.put("pageSize",20);
        body.put("beginTime",null);
        body.put("endTime",null);
        body.put("sort","captureTime");
        body.put("order","desc");
        body.put("isTotal",false);
        body.put("plateNo","苏DHE989");
        HttpEntity<Object> httpEntity = new HttpEntity<>(body,headers);
        log.info("httpEntity:{}",httpEntity);
        ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class);
        log.info("responseEntity:{}",responseEntity);
        return null;
    }


}


